/**
   simulator.h - Created by Timothy Morey on 2/2/2012.

   This file contains the definition of the Simulator object.
 */

#ifndef __SIMULATOR_H
#define __SIMULATOR_H

#include <pthread.h>

#include "../nvn/nvn-common/client.h"

class Simulator
{
public:
  Simulator(unsigned short width, unsigned short height);
  ~Simulator();

public:
  void Start();
  void Stop();
  void SingleStep();

  void SetSize(unsigned short width, unsigned short height);

  void RandomizeForest();

public:
  unsigned short GetWidth() const { return _Width; }
  unsigned short GetHeight() const { return _Height; }
  bool IsRunning() const { return _Running; }

  void PrintForest() const;

  void ExportDataToClient(Client* client);

protected:
  static void* SimThreadEntryPoint(void* arg);
  void SimThreadLoop();

protected:
  unsigned int* _Forest;
	char* _ForestImg;
  unsigned short _Width;
  unsigned short _Height;

  pthread_t _SimThread;
  bool _Running;
  bool _StopFlag;

  Client* _ExportTarget;
};

#endif
